package jupitermouse.site.example.java.batch;

import org.apache.flink.api.java.ExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

public class DataSetDataSourceJavaApp {
    public static void main(String[] args) throws Exception {
        final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        //从集合中读取
//        fromCollection(env);
        //从文件或者文件夹中读取
        fromtextFile(env);
    }

    public static void fromCollection(ExecutionEnvironment env) throws Exception {
        List<Integer> data = new ArrayList<>();
        for(int i = 0; i<10 ;i++){
            data.add(i);
        }
        env.fromCollection(data).print();
    }

    public static void fromtextFile(ExecutionEnvironment env) throws Exception {
        //读取文件
//        String inputPath = "file:///E:\\workroom\\learn\\flink\\demo_flink\\doc\\word.txt" ;
//        读取文件夹
        String inputPath = "file:///E:\\workroom\\learn\\flink\\demo_flink\\doc" ;
        env.readTextFile(inputPath).print();

    }
}
